package com.murfrosost.airhockey.activities;


import com.murfrosoft.airhockey.game.AirHockeyGame2;
import com.murfrosoft.airhockey.game.GameStats;
import com.murfrosost.airhockey.R;

import android.media.MediaPlayer;
import android.media.MediaPlayer.OnPreparedListener;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {

	MediaPlayer player;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		Button b = (Button)findViewById(R.id.button1);
		b.setText("Level "+GameStats.getLevel());
		TextView t = (TextView)findViewById(R.id.textView1);
		t.setText("lives: "+GameStats.getLives());
		player=MediaPlayer.create(this, R.raw.lament);
		player.setLooping(true);
	}
	
	

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		Button b = (Button)findViewById(R.id.button1);
		b.setText("Level "+GameStats.getLevel());
		TextView t = (TextView)findViewById(R.id.textView1);
		t.setText("lives: "+GameStats.getLives());
		player=MediaPlayer.create(this, R.raw.lament);
		player.setLooping(true);
		player.setOnPreparedListener(new OnPreparedListener() {
		    @Override
		    public void onPrepared(MediaPlayer mp) {
		        player.start();
		    }
		});
	}



	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		player.stop();
	}



	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}
	
	public void play(View view){
		Intent i = new Intent(this,AirHockeyActivity.class);
		this.startActivity(i);
	}

}
